﻿using System.Collections.Specialized;
using System.Configuration;

namespace EasyTask.EasyHelper
{
    /// <summary>
    /// Config文件操作
    /// </summary>
    public class Config
    {
        /// <summary>
        /// AppSettings配置
        /// </summary>
        public static NameValueCollection AppSettings => ConfigurationManager.AppSettings;

        /// <summary>
        /// 根据Key取Value值
        /// </summary>
        /// <param name="key"></param>
        public static string GetValue(string key) => AppSettings[key]?.ToString().Trim();

        /// <summary>
        /// 根据Key获取ConnectionString值
        /// </summary>
        /// <param name="key"></param>
        /// <returns></returns>
        public static string GetConnectionString(string key) => ConfigurationManager.ConnectionStrings[key]?.ConnectionString?.Trim();
    }
}
